package com.riko.comic.module.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.riko.comic.module.comic.bean.vo.ComicVo;
import com.riko.comic.module.sys.bean.po.ComicRank;
import com.riko.comic.module.sys.mapper.ComicRankMapper;
import com.riko.comic.module.sys.service.IComicRankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wudechuang
 * @since 2021-11-01
 */

@Service
public class ComicRankServiceImpl extends ServiceImpl<ComicRankMapper, ComicRank> implements IComicRankService {

    @Autowired
    private ComicRankMapper comicRankMapper;

    public ComicRank queryRank(ComicRank comicRank){
        return comicRankMapper.queryRank1(comicRank);
    }

    public Double queryRank(HashMap<String, Object> map){
        return comicRankMapper.queryRank2(map);
    }

    public void updateRankByIds(ComicRank comicRank){
        QueryWrapper<ComicRank> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", comicRank.getUserId()).eq("comic_id", comicRank.getComicId());
        comicRankMapper.update(comicRank, wrapper);
    }

    public Double queryAvgScore(Integer comicId){
        return comicRankMapper.queryAvgScore(comicId);
    }

    public List<ComicVo> ranking(){
        return comicRankMapper.ranking();
    }

    public List<ComicVo> dayRanking(HashMap<String, String> map){
        return comicRankMapper.dayRanking(map);
    }

    public List<ComicVo> monRanking(HashMap<String, String> map){
        return comicRankMapper.monRanking(map);
    }
}
